/*
 * Copyright 2010 Thedwick, LLC

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

 */
package com.thedwick.jdbcGrabber.sink;

import java.io.IOException;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

public class StdOutSummaryStore implements SummaryStore {

	public StdOutSummaryStore(Properties config){
		
	}
	
	@Override
	public void storeSQLTable(Map<Integer, NormalizedSQL> table) {
		System.out.println("+++++++++++++SQL Table START");
		for(Integer key : table.keySet()){
			NormalizedSQL sql = table.get(key);
			System.out.println(key + " is: " + sql.getSql());
		}
		System.out.println("+++++++++++++SQL Table END");
		
	}

	@Override
	public void updateSQLCounts(Map<Integer, Long> counts) {
		System.out.println("+++++++++++++SQL Counts START");
		for(Integer key : counts.keySet()){
			Long count = counts.get(key);
			System.out.println(key + " count is: " + count);
		}
		System.out.println("+++++++++++++SQL Counts END");
	}

	@Override
	public void storeTraceTable(Map<Integer, StackTraceElement[]> table) {
		System.out.println("+++++++++++++Trace Table START");
		for(Integer key : table.keySet()){
			StackTraceElement[] trace = table.get(key);
			System.out.println(key + " is: \n");
			for (StackTraceElement traceElem : trace){
				System.out.println("\t" + traceElem);
			}
		}
		System.out.println("+++++++++++++Trace Table END");
		
	}
	
	@Override
	public void storeTraceMapping(Map<Integer, Set<Integer>> sqlToTrace)
			throws IOException {
		System.out.println("+++++++++++++Trace Mapping START");
		for (Integer traceKey : sqlToTrace.keySet()){
			System.out.print(traceKey + " sql is called from these stack traces:");
			for (Integer sqlKey : sqlToTrace.get(traceKey)){
				System.out.print(sqlKey + ",");
			}
			System.out.println();
		}
		System.out.println("+++++++++++++Trace Mapping END");
		
	}

	@Override
	public void updateTraceCounts(Map<Integer, Long> counts) {
		System.out.println("+++++++++++++Trace Counts START");
		for(Integer key : counts.keySet()){
			Long count = counts.get(key);
			System.out.println(key + " count is: " + count);
		}
		System.out.println("+++++++++++++Trace Counts END");
		
	}

	
}